﻿using Abp.EntityFrameworkCore;
using Batman.Cms.Domains;
using Microsoft.EntityFrameworkCore;

namespace Batman.Cms.Core
{
    public class CmsDbContext : AbpDbContext
    {
        public CmsDbContext(DbContextOptions options) : base(options)
        {
        }

        public DbSet<Article> Articles { get; set; }

        public DbSet<ArticleType> ArticleTypes { get; set; }

        public DbSet<OpenAccount> OpenAccount { get; set; }

        public DbSet<QrCode> QrCode { get; set; }

        public DbSet<StopWordList> StopWordList { get; set; }

        public DbSet<Synonym> Synonym { get; set; }

        public DbSet<Application> Application { get; set; }
        public DbSet<ApplicationData> ApplicationData { get; set; }
        public DbSet<ApplicationDataItem> ApplicationDataItem { get; set; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity<ApplicationData>().HasMany(t => t.Children).WithOne(t => t.Parent).HasForeignKey(t => t.ParentId);
        }
    }
}
